/**************************************************************************************************
* Title: SumInputManager.h
* Author: Gael Huber
* Description: Manager for all game input. Manages polling for input as well as updating input
*	values.
**************************************************************************************************/
#ifndef __SUMINPUTMANAGER_H__
#define __SUMINPUTMANAGER_H__

// DirectInput version
#define DIRECTINPUT_VERSION 0x0800

#include "SumSingleton.h"
#include "SumKeyboard.h"
#include "SumMouse.h"
#include "SumRenderWindow.h"
#include "SumJobManager.h"

class InputManager : public Singleton<InputManager> {
public:
	InputManager(void);		// Constructor
	virtual ~InputManager(void);	// Destructor

	// Get singleton
	inline static InputManager& getSingleton(void) 
	{
		assert(singleton);
		return *singleton;
	}

	// Get singleton pointer
	inline static InputManager* getSingletonPtr(void)
	{
		return singleton;
	}

	void startUp(void);		// Start-up function for this engine subsystem
	void shutDown(void);	// Shut down fnction for this engine component

	static void kickPollInput(void* p);	// Request a job to poll for input
	void pollInput(void);	// Poll for input

	int getKeyPressed(int code) const;	// Checks whether a particular key is being pressed
	const DIMOUSESTATE& getMouseState(void) const;	// Returns the current mouse state

private:
	LPDIRECTINPUT8 inputDevice;		// DirectInput device
	Keyboard* keyboard;				// The keyboard device
	Mouse* mouse;					// The mouse device
};

// Assign the proper function to a job, this gives a cleaner way of creating upper level engine jobs
void AssignInputFunction(Job& job);

// Request input from the hardware
void RequestInput(Job& job);

// Wait for input polling to finish
void WaitForInput(Job& job);

// Request a keyboard code to see whether it is currently pressed
int GetKeyboardCode(int code);

// Returns the current mouse state
const DIMOUSESTATE& GetMouseState(void);

#include "SumInputManager.inl"

#endif